#include<iostream>
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int allm = c*60+d-(a*60+b);
    cout<<allm/60<<" "<<allm%60<<endl;
    return 0;
}
